const del        = require('del'),
      path       = require('path'),
      gulp       = require('gulp'),
      clean      = require('gulp-clean-css'),
      filter     = require('gulp-filter'),
      rename     = require('gulp-rename'),
      postcss    = require('gulp-postcss'),
      sourcemaps = require('gulp-sourcemaps');

const SRC = './src/', DIST = './dist/', pkg = require('./package.json');

gulp.task('del', cb => del(DIST, cb));

gulp.task('default', ['del'], () => {

    gulp.src(SRC + 'ui.pcss')
        .pipe(rename({
            basename: pkg.name,
            extname: '.css'
        }))
        .pipe(sourcemaps.init())
        .pipe(postcss())
        .pipe(sourcemaps.write('.'))
        .pipe(gulp.dest(DIST))
        .pipe(filter('**/*.css'))
        .pipe(clean({
            compatibility: 'ie8'
        }))
        .pipe(rename({
            extname: '.min.css'
        }))
        .pipe(gulp.dest(DIST));
});